package model;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name = "direction")
public class Direction extends Link implements Serializable
{
	private static final long serialVersionUID = -7237701223168478986L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name = "";
	
	@XmlElement(name = "group")
	private ArrayList<Group> groups = new ArrayList<Group>();
	
	public Direction() {}
	
	public Direction(String name)
	{
		i++;
		this.id = i + "";
		this.name = name;
	}
	
	public Group createGroup(String name, String description)
	{
		Group group = new Group(name, description);
		groups.add(group);
		return group;
	}

	public ArrayList<Group> getGroups()
	{
		return groups;
	}
	
	public String toString()
	{
		String out = "";
		for (int i = 0; i < groups.size(); i++)
		{
			out += groups.get(i) + "\n";
		}
		return "Direction id(" + id + ") -> Name: " + name + "\n" + out;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}
}
